from ..attributes import *
from ..attributes import _

from .structure import *


class Text(Element):
    text = Attribute()
    
    element_function =_ ('create_text')


class Data(Text):
    field  = Attribute()
    source = Attribute()
    
    @property
    def text(self):
        return str(self.source())
    
    @property
    def is_data(self):
        return True
    
    def bind_sources(self, sources):
        if self.field in sources:
            self.source = sources[self.field]

    def bind_classes(self, classes):
        if self.field in classes:
            self.class_conditions = classes[self.field]


class Image(Element):
    element_function =_ ('create_image')


class Button(Element):
    element_function =_ ('create_button')
